package partner

import (
	. "chess_platform/internal/common"
	"fmt"
	"github.com/astaxie/beego/orm"
)

//TODO:要做缓存
//总代及代理第一次充值
func TopUpByLevel(level int64, multiOrm ...orm.Ormer) (TopUp, error) {
	sql := fmt.Sprintf(`
		SELECT
			*
		FROM
			%v
		WHERE
			level = ?
		LIMIT 1
		`, TableH5TopUp)
	o := NewOrm(multiOrm, DBChessSysData)
	var tu TopUp
	err := o.Raw(sql, level).QueryRow(&tu)
	if CheckNoExist(err) {
		return tu, nil
	}
	return tu, err
}
